package pl.kosmowska.ewelina.server.jdo;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.VersionStrategy;

import pl.kosmowska.ewelina.server.PMF;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="version", extensions={@Extension(vendorName="datanucleus", key="key", value="version")})
public class SavingsData implements DatabaseEntity<String>{

	@NotPersistent
	private static final Logger log = Logger.getLogger(SavingsData.class.getName());

	/**
	 * primary id
	 * transposed to web safe id (base64) for transport
	 */
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private Long version;

	/**
	 * entity owner - the person who's logged in
	 */
	@Persistent
	private Long userId; 


	@Persistent
	private String name;

	@Persistent
	private float value;
	

	@Persistent
	private Date startDate;
	
	@Persistent
	private Date endDate;

	@Persistent
	private float valuePaid;
	
	@Persistent
	private float valueNotPaid;
	
	@Persistent
	private String sponsoredOutcomeId;
	
	public String getSponsoredOutcomeId() {
		return sponsoredOutcomeId;
	}

	public void setSponsoredOutcomeId(String sponsoredOutcomeId) {
		this.sponsoredOutcomeId = sponsoredOutcomeId;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public float getValuePaid() {
		return valuePaid;
	}

	public void setValuePaid(float valuePaid) {
		this.valuePaid = valuePaid;
	}

	public float getValueNotPaid() {
		return valueNotPaid;
	}

	public void setValueNotPaid(float valueNotPaid) {
		this.valueNotPaid = valueNotPaid;
	}


	public float getValue() {
		return value;
	}

	public void setValue(float value) {
		this.value = value;
	}

	
	public void setId(String id) {
		if (id == null) {
			return;
		}
		key = KeyFactory.stringToKey(id);
	}
	public String getId() {
		String id = null;
		if (key != null) {
			id = KeyFactory.keyToString(key);
		}
		return id;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	public Long getVersion() {
		if (version == null) {
			version = 0l;
		}
		return version;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public Long getUserId() {
		return userId;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}




}
